package argirithm;
//10 转换其他进制
public class Demo02 {
    public static void main(String[] args) {
        String str = toString(66,2);
        System.out.println(str);
    }


    final static char[] digi = {'0','1','2','3','4','5','6','7','8','9'};
    public static String toString(int num,Integer radix){
        boolean negative = false;
        if (num < 0){
            negative=true;
            num = -num;
        }
        char[] chars = new char[32];
        int index = chars.length-1;
        do {
            int last = num%radix;
            char c = digi[last];
            chars[index --] = c;
            num /= radix;
        }while (num !=0);
        if (negative){
            chars[index--] = '-';
        }
        return new String(chars,index+1,chars.length-index-1);
    }
}
